package com.ruoyi.web.api.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysRescueStation;
import com.ruoyi.system.service.ISysRescueStationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 救助站信息Controller
 *
 * @author ruoyi
 */
@Api(tags = "救助站管理")
@RestController
@RequestMapping("/system/station")
public class SysRescueStationController extends BaseController {
    private final ISysRescueStationService sysRescueStationService;

    public SysRescueStationController(ISysRescueStationService sysRescueStationService) {
        this.sysRescueStationService = sysRescueStationService;
    }

    /**
     * 查询救助站信息列表
     */
    @ApiOperation(value = "获取救助站列表", notes = "获取所有救助站信息")
    @GetMapping("/list")
    public TableDataInfo list(SysRescueStation sysRescueStation) {
        startPage();
        List<SysRescueStation> list = sysRescueStationService.selectSysRescueStationList(sysRescueStation);
        return getDataTable(list);
    }

    /**
     * 导出救助站信息列表
     */
    @ApiOperation(value = "导出救助站信息", notes = "导出所有救助站信息数据")
    @Log(title = "救助站信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SysRescueStation sysRescueStation) {
        List<SysRescueStation> list = sysRescueStationService.selectSysRescueStationList(sysRescueStation);
        ExcelUtil<SysRescueStation> util = new ExcelUtil<>(SysRescueStation.class);
        return util.exportExcel(list, "救助站信息数据");
    }

    /**
     * 获取救助站信息详细信息
     */
    @ApiOperation(value = "获取救助站详细信息", notes = "根据id获取救助站详细信息")
    @ApiImplicitParam(name = "id", value = "救助站ID", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(sysRescueStationService.selectSysRescueStationById(id));
    }
}